<?php
//生成验证码
$image=  imagecreatetruecolor(80, 25);


$c1=rand(100,255);
$c2=rand(100,255);
$c3=rand(100,255);
$bc = imagecolorallocate($image, $c1, $c2, $c3);
imagefill($image, 0, 0, $bc);
$str="abcdefghijklmnopqrstuvwxyz1234567890";

for($i=1;$i<=4;$i++)
{
$q1=rand(0,150);
$q2=rand(0,150);
$q3=rand(0,150);
$qc = imagecolorallocate($image, $q1, $q2, $q3);
$char=substr($str,rand(0,35),1);
imagechar($image, 5, 10+$i*10, rand(1,10), $char, $qc);

}
//产生干扰
for($i=1;$i<=10;$i++)
{
$c1=rand(100,255);
$c2=rand(100,255);
$c3=rand(100,255);
$bc = imagecolorallocate($image, $c1, $c2, $c3);
imagechar($image, 1, rand(0,99), rand(1,24),"*", $bc);
}


header("Content-Type:image/png");
imagepng($image);
imagedestroy($image);

